package com.example.yiqiuser.service.impl;


import com.example.yiqiuser.dao.TDicGchannelDao;
import com.example.yiqiuser.entity.TDicGchannel;
import com.example.yiqiuser.service.TDicGchannelService;
import com.example.yiqiuser.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 攻略栏目(TDicGchannel)表服务实现类
 *
 * @author makejava
 * @since 2023-04-03 10:51:52
 */
@Service
public class TDicGchannelServiceImpl implements TDicGchannelService {
    @Resource
    private TDicGchannelDao tDicGchannelDao;

    @Override
    public PageInfo queryPage(Page<TDicGchannel> page) {
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new PageInfo(tDicGchannelDao.queryByParam(page.getData()));
    }

    @Override
    public List<TDicGchannel> queryAll() {
        TDicGchannel tDicGchannel = new TDicGchannel();
        return tDicGchannelDao.queryByParam(tDicGchannel);
    }

    @Override
    public TDicGchannel queryById(Integer code) {
        List<TDicGchannel> tDicGchannels = tDicGchannelDao.queryById(code);
        if (tDicGchannels != null && tDicGchannels.size() > 0) {
            return tDicGchannels.get(0);
        }
        return null;
    }

    @Override
    public int insert(TDicGchannel tDicGchannel) {
        return tDicGchannelDao.insert(tDicGchannel);
    }

    @Override
    public int update(TDicGchannel tDicGchannel) {
        return tDicGchannelDao.update(tDicGchannel);
    }

    @Override
    public int deleteById(int code) {
        return tDicGchannelDao.deleteById(code);
    }
}
